import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'
import Home from '../views/Home.vue'
import stuInfo from '../views/manage/stuInfo.vue'
import stuScore from '../views/manage/stuScore.vue'
import lookScore from '../views/student/lookScore.vue'
import teaInfo from '../views/manage/teaInfo.vue'

Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}   

const routes = [
  {
    path: '/',
    name: 'login',
    component: Login,
    meta: {
      title: '欢迎登录成绩管理系统'
    }
  },
  {
    path: '/home',
    name: 'home',
    component: Home,
    meta: {
      requireAuth: true,
      title:'成绩管理系统'
    },
    children: [
      {
        path: '/home/stuInfo',
        name: 'stuInfo',
        component: stuInfo
      },
      {
        path: '/home/teaInfo',
        name: 'teaInfo',
        component: teaInfo
      },
      {
        path: '/home/stuScore',
        name: 'stuScore',
        component: stuScore
      },
      {
        path: '/home/lookScore',
        name: 'lookScore',
        component: lookScore
      },
    ]
  },
]

const router = new VueRouter({
  mode: 'hash',
  routes
})

export default router

